MESSAGE:=message

MESSAGE_BASEDIR:=$(BASEDIR)/$(MESSAGE)

MESSAGE_CC:=g++
MESSAGE_LD:=g++

#MESSAGE_MODULES_DEPENDENCIES:=mydb myfile mythread
MESSAGE_MODULES_DEPENDENCIES:=

MESSAGE_INCFLAGS:=-I$(MESSAGE_BASEDIR)/inc -I$(BASEDIR)/common/inc $(patsubst %, -I$(BASEDIR)/%/inc, $(MESSAGE_MODULES_DEPENDENCIES))

ifeq ($(SYSTEM), MINGW32_NT-5.1)
MESSAGE_DEBUG_CFLAGS:=-g -Wall -W -pedantic -Woverloaded-virtual -D_REENTRANT -DDEBUG $(MESSAGE_INCFLAGS)
MESSAGE_DEBUG_LDFLAG:=
MESSAGE_DEBUG_LIBS:=

MESSAGE_RELEASE_CFLAGS:=-Wall -W -pedantic -Woverloaded-virtual -D_REENTRANT -DRELEASE $(MESSAGE_INCFLAGS)
MESSAGE_RELEASE_LDFLAG:=
MESSAGE_RELEASE_LIBS:=
endif

ifeq ($(SYSTEM), Linux)
MESSAGE_DEBUG_CFLAGS:=-g -Wall -fPIC -W -pedantic -Woverloaded-virtual -D_REENTRANT -DDEBUG $(MESSAGE_INCFLAGS)
MESSAGE_DEBUG_LDFLAG:=
MESSAGE_DEBUG_LIBS:=

MESSAGE_RELEASE_CFLAGS:=-Wall -W -fPIC -pedantic -Woverloaded-virtual -D_REENTRANT -DRELEASE $(MESSAGE_INCFLAGS)
MESSAGE_RELEASE_LDFLAG:=
MESSAGE_RELEASE_LIBS:=

endif

MESSAGE_SRC:=$(shell ls 2>&1 $(MESSAGE_BASEDIR)/src/*.cpp)

TMP_MESSAGE_OBJ:= $(patsubst %.cpp,%.o,$(filter %.cpp,$(MESSAGE_SRC)))
TMP_MESSAGE_DEP:= $(patsubst %.cpp,%.d,$(filter %.cpp,$(MESSAGE_SRC)))

SRC+=$(MESSAGE_SRC)

MESSAGE_DEBUG_OBJS=$(shell echo $(TMP_MESSAGE_OBJ) | sed -e 's@src@obj/debug@g' )
MESSAGE_RELEASE_OBJS+=$(shell echo $(TMP_MESSAGE_OBJ) | sed -e 's@src@obj/release@g' )

DEBUG_OBJS+=$(MESSAGE_DEBUG_OBJS)
RELEASE_OBJS+=$(MESSAGE_RELEASE_OBJS)

# Dependencies are release independant.
DEPS+=$(shell echo $(TMP_MESSAGE_DEP) | sed -e 's@src@dep@g' )

DEBUG_MESSAGE_ARCHIVE:=$(BASEDIR)/lib/debug/$(MESSAGE).a
RELEASE_MESSAGE_ARCHIVE:=$(BASEDIR)/lib/release/$(MESSAGE).a

DEBUG_MESSAGE_LIB:=$(BASEDIR)/lib/debug/lib$(MESSAGE).so
RELEASE_MESSAGE_LIB:=$(BASEDIR)/lib/release/lib$(MESSAGE).so

DEBUG_ARCHIVES+=$(DEBUG_MESSAGE_ARCHIVE)
RELEASE_ARCHIVES+=$(RELEASE_MESSAGE_ARCHIVE)

DEBUG_LIBS+=$(DEBUG_MESSAGE_LIB)
RELEASE_LIBS+=$(RELEASE_MESSAGE_LIB)
